@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/jquery.form.css')}}" type="text/css" rel="stylesheet" />

    <script src="{{url('/js/lib/jquery.form.js')}}"></script>

    <style>
        .btn_add_classify{
            background: #31bcd3;margin-left:10px;height: 5px;width: 50px;color: white;text-align: center;padding:5px;border-radius:7px;box-shadow: 3px 2px 9px #888888;
        }
    </style>
@endsection

@section('html-body')
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <em></em>
            <a href="#">分类列表</a>
        </div>


        <div class="filter-box clearfix">
            <div class="fr">
                <a class="addBtn" href="{{route('Admin.Home.contentSet')}}" >新增</a>
            </div>
        </div>

        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>标题</th>
                    <th>链接</th>
                    <th>父级分类</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @if(count($content) > 0)
                    @foreach($content as $con)
                        <tr id="classify_{{$con->id}}">
                            <td>{{$con->id}}</td>
                            <td>
                                <span id="classify_name_{{$con->id}}">{{$con->title}}</span>
                            </td>
                            <td>{{$con->link_url}}</td>
                            <td>{{$con->c_title}}</td>
                            <td>
                                <a href="{{route('Admin.Home.contentSet')}}?id={{$con->id}}" style="color: #ef1414;" )">编辑</a> |
                                <a href="javascript:void(0);" class="del" data-id="{{$con->id}}" >删除</a>
                            </td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
            </table>
        </div>
    </div>

    <script>

        $(function(){

            $(document).on("click",".del",function(){
                var id = $(this).attr("data-id");
                noty({
                    text: '可能影响分类内容，你确定要删除吗?',
                    buttons: [
                        {addClass: 'btn btn-primary', text: '确定', onClick: function($noty) {
                                $noty.close();
                                $.ajax({
                                    url:'{{route('Api.Admin.sys.delContent')}}',
                                    type:'post',
                                    dataType:'json',
                                    data:{id:id},
                                    success:function(obj){
                                        if(obj.level == "success"){
                                            $("#classify_"+id).hide('slow');
                                        }else{
                                            noty({type:obj.level,text:obj.message,timeout:600});
                                        }
                                    },
                                    error:function(obj){
                                        console.log(obj);
                                    }

                                });
                            }
                        },
                        {addClass: 'btn btn-danger', text: '取消', onClick: function($noty) {
                                $noty.close();
                            }
                        }
                    ]
                });

            });

        });
    </script>
@endsection